//
//  ModulesConfig.swift
//  JKTool
//
//  Created by 姜奎 on 2023/5/23.
//

import Foundation

public class ModulesConfigs {
    
    struct Config: Decodable {
        var checkouts: String = "Module/checkouts"
        var builds: String = "Module/Builds"
        var build: String = "build"
        var toolUrl: String = ""
        var completionUrl: String = ""
        var zshCompletionUrl: String = ""
    }
    
    var config: Config
    
    static let sharedInstance = ModulesConfigs()
    
    private init() {
        let url = URL(fileURLWithPath: "\(FileManager.userDirectory())/Library/Containers/com.jk.JKTools/Data/Documents/config.json")
        if let data = try? Data(contentsOf: url),let config = try? JSONDecoder().decode(Config.self, from: data) {
            self.config = config
        } else {
            self.config = Config()
        }
    }

    static let documentBinPath = "\(FileManager.userDirectory())/Library/Containers/com.jk.JKTools/Data/Documents/bin"

    static let documentZshSharePath = "\(FileManager.userDirectory())/Library/Containers/com.jk.JKTools/Data/Documents/share/zsh/site-functions"

    static let documentBashSharePath = "\(FileManager.userDirectory())/Library/Containers/com.jk.JKTools/Data/Documents/share/bash_profile/site-functions"

    static let resourceBinPath = "/Applications/JKTools.app/Contents/Resources/bin"

    static let resourceSharePath = "/Applications/JKTools.app/Contents/Resources/share/zsh/site-functions"
}
